const Router = require('koa-router')
const { koaBody } = require('koa-body')

// 创建地址为‘role/xxx’的api地址
const router = new Router({ prefix: '/activity' })

// 导入中间件
const { auth } = require('../middleware/auth.middleware')
const {
    judgeCreateUserPwoer,
    actCreateValidator,
    actImgKoaBody,
    judgeApprovalUserPwoer,
    actIsApproval,
    actIdIsExist,
    determineTime,
    determineStartEndTime,
    determineLoaction,
    entryKoaBody,
    uploadEntryFormat,
    getSignScoreTypeAndScore,
    determineScoreApprovalTime
} = require('../middleware/activity.middleware')

// 导入controller层
const {
    createACT,
    editACT,
    approvalACT,
    getACTList,
    getACTInfoById,
    getACTImgById,
    getAllACTImg,
    createFeedback,
    getFeedbackList,
    handleFeedback,
    uploadEntry
} = require('../controller/activity.controller')

const {
    actBouns,
    getActScoreFile,
    getChuangxinByAccount,
    getXueyeByAccount,
    getSixiangByAccount,
    getWentiByAccount,
    addLocation,
    isSetLoaction,
    approvalScoreFile,
    getEntryList,
    marchActBouns,
    getActScoreType
} = require('../controller/actScore.controller')



// 创建活动
router.post('/createACT', auth, judgeCreateUserPwoer, actImgKoaBody, actCreateValidator, createACT)
// 修改活动
router.post('/editACT', auth, koaBody({ multipart: true }), editACT)
// 审批活动
router.post('/approvalACT', auth, koaBody({ multipart: true }), judgeApprovalUserPwoer, actIsApproval, approvalACT)
// 按传入字段的需求获取活动列表
router.get('/getACT', getACTList)
// 获取单个活动的详细内容
router.get('/getDetailInfo', auth, actIdIsExist, getACTInfoById)
// 获取单个活动的所有图片
router.get('/getACTImg', auth, actIdIsExist, getACTImgById)
// 获取所有图片
router.get('/getACTAllImg', getAllACTImg)

// 创建活动反馈
router.post('/createFeedback', auth, koaBody({ multipart: true }), createFeedback)
// 处理活动反馈
router.post('/handleFeedback', auth, koaBody({ multipart: true }), handleFeedback)
// 获取活动反馈列表
router.get('/getFeedback', auth, koaBody({ multipart: true }), getFeedbackList)

// 时间签到活动加分
router.post('/signScore', auth, koaBody({ multipart: true }), determineStartEndTime, getSignScoreTypeAndScore, actBouns)

// 定位签到活动加分
router.post('/signLocationScore', auth, koaBody({ multipart: true }), isSetLoaction, determineStartEndTime, determineLoaction, getSignScoreTypeAndScore, actBouns)
// 增加活动签到位置
router.post('/addLoaction', auth, koaBody({ multipart: true }), addLocation)

// 比赛提交文件
router.post('/submitEntry', auth, entryKoaBody, determineTime, uploadEntryFormat, uploadEntry)
// 获取参赛文件列表
router.get('/getEntryList', auth, getEntryList)
// 比赛提交文件加分(活动组织者评分)
router.post('/marchScore', auth, koaBody({ multipart: true }), marchActBouns)


// 获取活动加分类型
router.get('/getActScoreType', auth, getActScoreType)

// 获取某活动加分文件
router.get('/getActScoreFile', auth, getActScoreFile)
// 获取某学生创新分
router.get('/getChuangxinByAccount', auth, getChuangxinByAccount)
// 获取某学生学业分
router.get('/getXueyeByAccount', auth, getXueyeByAccount)
// 获取某学生思想分
router.get('/getSixiangByAccount', auth, getSixiangByAccount)
// 获取某学生文体分
router.get('/getWentiByAccount', auth, getWentiByAccount)
// 某活动加分名单通过审批
router.post('/approvalScoreFile', auth, koaBody({ multipart: true }), determineScoreApprovalTime, approvalScoreFile)


module.exports = router